package com.itheima.Controller;

import com.itheima.pojo.CountOption;
import com.itheima.pojo.JobOption;
import com.itheima.pojo.Result;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportServiceImpl;

    /**
     * 员工性别统计,饼状图
     * @return
     */
    @GetMapping("/empGenderData")
    public Result empGenderData(){
//        调用Service层方法,返回数据
        List<Map<String,Object>> list =  reportServiceImpl.empGenderData();
//        返回Result
        return Result.success(list);
    }


    /**
     * 员工职位统计,柱状图
     * @return
     */
    @GetMapping("/empJobData")
    public Result empJobData(){
//        调用Service层方法
        JobOption jobOption =  reportServiceImpl.empJobData();
//        返回Result
        return Result.success(jobOption);
    }


    /**
     * 学员学历统计，饼状图
     * @return
     */
    @GetMapping("/studentDegreeData")
    public Result studentDegreeData(){
//        1.调用Mapper层方法
        List<Map<String,Integer>> list = reportServiceImpl.studentDegreeData();

//        2.返回Result
        return Result.success(list);
    }


    /**
     * 班级人数统计，柱状图
     * @return
     */
    @GetMapping("/studentCountData")
    public Result studentCountData(){
//        1.封装成CountOption对象
        CountOption countOption = reportServiceImpl.studentCountData();
//        2.返回Result
        return Result.success(countOption);
    }

}
